package com.springboot.properties.entity;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * @Desc: 使用 @Component @PropertySource @ConfigurationProperties 三个注解，
 * 就可以将一个配置文件 中的属性和属性值 赋值到一个 JavaBean 中。
 * @Date: 2020-07-10
 * @Version:v1.0
 */
@Component
@PropertySource(value = "classpath:test.properties")
@ConfigurationProperties(prefix = "com.forezp")
public class CustomerBeanEntity {

    private String name;

    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "CustomerBeanEntity{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
